package com.cn.qgx428.lazydiary.ui.activity.subActivity

import android.content.Context
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.widget.LinearLayout
import android.widget.TextView
import com.cn.qgx428.lazydiary.R
import com.cn.qgx428.lazydiary.Utils.MConst
import com.cn.qgx428.lazydiary.adapter.RAdapter
import com.cn.qgx428.lazydiary.adapter.RViewHolder
import com.cn.qgx428.lazydiary.network.bean.PlanClockIn
import com.cn.qgx428.lazydiary.ui.activity.BaseActivity
import kotlinx.android.synthetic.main.activity_plan_hictivity.*
import kotlinx.android.synthetic.main.activity_plan_history.*

class PlanHIctivity : BaseActivity() {

    lateinit var planClockIn : PlanClockIn
    val adapter = IAdapter(this, R.layout.adapter_plan_clock_in_re)

    override fun initUI() {
        hindActionBar()
        setStatuBarColor(R.color.myGreenBlack)
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_plan_hictivity)
        planClockIn = intent.extras.getSerializable(MConst.PLAN_CLOCK_IN_DETAIL) as PlanClockIn
        initView()
    }

    private fun initView() {
        planHI_re.adapter = adapter
        planHI_re.layoutManager = LinearLayoutManager(this)
        planHI_bar.setBackOnClickListener { finish() }
        planHI_bar.setTitle(planClockIn.time)
        planHI_remark.text = planClockIn.remark
        //
        val items = planClockIn.content.split(",")
        adapter.setDatas(items as MutableList<String>)
    }

    class IAdapter: RAdapter<String>{
        constructor(context: Context, layoutId: Int): super(context,layoutId)

        override fun conver(holder: RViewHolder, data: String) {
            val text = holder.getView<TextView>(R.id.adapter_plan_clockIn_text)
            text?.text = data
        }
    }
}
